package form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class AddEmployeForm extends ActionForm {
	/**
	 * 
	 */
	protected String nom = "";
	protected String prenom = "";
	protected String mail = "";
	protected int contratHoraire = 0;
	protected String password = "";
	protected String repassword = "";
	protected String sexe = "";
	protected String adresse = "";
	protected int telephone = 0;
	protected String civilite = "";
	protected int cp = 0;
	protected String ville = "";
	protected String login="";
	
	private static final long serialVersionUID = 1L;
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) {
		ActionErrors errors = new ActionErrors ();
		
		if (this.nom == null || this.nom.length() == 0)
			errors.add("nom", new ActionMessage ("empty"));
		else if (this.login.length() == 0)
			errors.add("login", new ActionMessage("empty"));
		else if (this.prenom == null || this.prenom.length() == 0)
			errors.add("prenom", new ActionMessage("empty"));
		else if (this.password == null || this.password.length() == 0)
			errors.add("password", new ActionMessage("empty"));
		else if (this.repassword.length() == 0)
			errors.add("repassword", new ActionMessage("empty"));
		else if (this.mail.length() == 0)
			errors.add("mail", new ActionMessage("empty"));
		//else if (this.mail.matches("^*@*.*$") == false)
		//	errors.add("mail", new ActionMessage("invalid mail"));
		else if (this.password.compareTo((this.repassword)) != 0)
			errors.add("password", new ActionMessage("notsame"));
		
		return errors;
		}
	
	public void reset(ActionMapping mapping, HttpServletRequest request) 
	{
		this.password = "";
		this.repassword = "";
	}

	public String getAdresse() 
	{
		return adresse;
	}

	public void setAdresse(String adresse) 
	{
		this.adresse = adresse;
	}

	public int getContratHoraire() 
	{
		return contratHoraire;
	}

	public void setContratHoraire(int contratHoraire) 
	{
		this.contratHoraire = contratHoraire;
	}

	public String getMail() 
	{
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getRepassword() {
		return repassword;
	}

	public void setRepassword(String repassword) {
		this.repassword = repassword;
	}

	public String getSexe() {
		return sexe;
	}

	public void setSexe(String sexe) {
		this.sexe = sexe;
	}

	public int getTelephone() {
		return telephone;
	}

	public void setTelephone(int telephone) {
		this.telephone = telephone;
	}

	public String getCivilite() {
		return civilite;
	}

	public void setCivilite(String civilite) {
		this.civilite = civilite;
	}

	public int getCp() {
		return cp;
	}

	public void setCp(int cp) {
		this.cp = cp;
	}

	public String getVille() {
		return ville;
	}

	public void setVille(String ville) {
		this.ville = ville;
	}

	/**
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * @param login the login to set
	 */
	public void setLogin(String login) {
		this.login = login;
	}

}
